#include "server_UDP.hpp"
#include <memory>
#include "dict.hpp"
#include "route.hpp"
#include "thread_pool.hpp"
#include <functional>

std::string Echo(const std::string& str)
{
    std::string ret = "echo@ ";
    ret += str;
    return ret;
}


//using std::function<>

int main(int argc, char* argv[])
{
    //./server_UDP [server_port] [server_ip] //不用传ip, 因为INADDR_ANY

    //./server_UDP [server_port]
    if(argc != 2)
    {
        std::cout << "usage: " << argv[0] << " [server_port]" << std::endl;
        return 1;
    }
    uint16_t port = static_cast<uint16_t>(std::stoi(argv[1]));
    

    //1.路由对象
    route r;

    //2.线程池

    
    //3.网络服务器对象
    std::unique_ptr<server_udp> s_p = std::make_unique<server_udp>(port, [&r](int socket_fd, const std::string& message, const Inet_Addr& server_user)
                                                                         {
                                                                             r.message_route(socket_fd, message, server_user);
                                                                         }                                                                              );
    s_p->start();

    return 0;
}